<?php

class Account_model extends CI_Model
{

    public function getLoginInfo($user)
    {
        $this->db->select('A.*')
            ->from('users A')
            ->where('A.user', $user);

        $query = $this->db->get();
        $rt = array();
        if ($query->num_rows() > 0) {

            $rt = $query->row_array(0);
        }
        $query->free_result();
        return $rt;
    }

    public function update($array, $cond)
    {
        $this->db->where($cond);
        return $this->db->update('users', $array);
    }

    public function getAllUsers()
    {
        $this->db->select('A.*')
            ->from('users A');

        $query = $this->db->get();
        $rt = array();
        if ($query->num_rows() > 0) {

            $rt = $query->result_array();
        }
        $query->free_result();
        return $rt;
    }

    public function removeUser($id)
    {
        return $this->db->delete('users', array(
            'id' => $id
        ));
    }

    public function addUser($arr)
    {
        return $this->db->insert('users', $arr);
    }

}
